home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / qbsub10.arc / WINDODMO.ASC < prev    next >
Encoding:
Text File  |  1986-06-25  |  6.9 KB  |  314 lines

  1. 'WINDODMO.ASC -- MSDOS QuickBASIC WINDOW.SUB demonstration    25 June 86
  2. '|         by David L. Poskie     (608) 274-9560
  3. '|                   7118 Raymond Rd. Madison, WI 53719
  4. '|  Please run any suggestions, corrections, additions, or changes by me.
  5. '|  I can be messaged on all the major Madison, WI RBBS's.
  6.  
  7.     DEFINT A-C,E-Z           ' All variables except D are integers
  8.     False = 0         '  (D must be SNG for Delay subroutine)
  9.     True = NOT False
  10.  
  11.     ' The next two code lines come from WINDOW.SUB, where I have
  12.     '  them commented out. This is my preference -- I like to see
  13.     '  all the DIMensioning right up front in a main program. If you
  14.     '  are less picky, you could uncomment them in WINDOW.SUB and omit
  15.     '  writing these lines. 
  16.      DIM HSelect$(10) , VSelect$(10) , SaveWindow$(100)
  17.      DIM NowX(20) , NowY(20) , NowWidth(20) , HeightNow(20)
  18.     ' In general, NOW refers to the current window.
  19.  
  20. GOTO Start
  21.     'You must include these two subroutine files to use windows
  22.     Rem    $Include: 'OMNI.SUB'
  23.     Rem    $Include: 'WINDOW.SUB'
  24.  
  25. Start:    
  26.     'Set and save the original screen attributes
  27.     OldFG = 14
  28.     OldBG = 3
  29.     OldMG = 8
  30.     COLOR OldFG , OldBG , OldMG
  31.  
  32.     CLS 
  33.     LOCATE 10 , 30 
  34.     PRINT "Microsoft QuickBASIC"
  35.     LOCATE 12 , 20 
  36.     PRINT "Demonstration of WINDOW.SUB Subroutines"
  37.  
  38.      ' Set the screen attributes for the first window
  39.     ScreenWidth = 80
  40.     FG = 14 
  41.     BG = 6 
  42.     MG = 8 
  43.     COLOR FG , BG , MG
  44.  
  45.     ' Set the location & dimensions
  46.     DoubleBox = True                ' Use a double line box
  47.     NewWindow = True
  48.     X = 2 
  49.     Y = 2
  50.     WWidth = 76 
  51.     WHeight = 19
  52.  
  53.     ' Make the window
  54.     GOSUB AddWindow 
  55.  
  56.     '| Display text on first window
  57.     W = 1
  58.     X = 6 
  59.     Y = 3 
  60.     Text$ = "     This demonstration shows you how QuickBASIC can be used for"
  61.     GOSUB WriteWindow
  62.     Y = Y + 1
  63.     Text$ = "making windows and menus.  The delay you experienced in getting"
  64.     GOSUB WriteWindow
  65.     Y = Y + 1
  66.     Text$="to here was caused by the routine that saved the information"
  67.     GOSUB WriteWindow
  68.     Y = Y + 1
  69.     Text$ = "underlying this window."
  70.     GOSUB WriteWindow
  71.     Y = Y + 2
  72.     Text$ = "     Windows can help a program user understand what can be done"
  73.     GOSUB WriteWindow
  74.     Y = Y + 1
  75.     Text$ = "at any given time in the program . They can provide  a clear way of"
  76.     GOSUB WriteWindow
  77.     Y = Y + 1
  78.     Text$ = "displaying multiple events on one screen. They can also be used for"
  79.     GOSUB WriteWindow
  80.     Y = Y + 1
  81.     Text$ = " showing menu selections or other prompts, as demonstrated here."
  82.     GOSUB WriteWindow
  83.     Y = Y + 2
  84.     Text$ = "     To make a selection, just use the arrow keys to `point' to"
  85.     GOSUB WriteWindow
  86.     Y = Y + 1
  87.     Text$ = "your choice. On a horizontal menu, use the left and right keys"
  88.     GOSUB WriteWindow
  89.     Y = Y + 1
  90.     Text$ = "the select your choice. On a vertical, `pull-down' menu, use"
  91.     GOSUB WriteWindow
  92.     Y = Y + 1
  93.     Text$ = "the up and down arrow keys.  Once your selection has been made,"
  94.     GOSUB WriteWindow
  95.     Y = Y + 1
  96.     Text$ = "press <CR>.  That's all there is to it !"
  97.     GOSUB WriteWindow
  98.  
  99. MainLoop:
  100.     DoubleBox = False                ' Use a single line box
  101.     W = 1
  102.     HSelectWidth = 10
  103.     HSelect$(1) = "Edit"
  104.     HSelect$(2) = "Files"
  105.     HSelect$(3) = "Print"
  106.     HSelect$(4) = "Help"
  107.     HSelect$(5) = "Exit"
  108.     HNumSelects = 5
  109.  
  110.      '| Display horizontal menu
  111.     GOSUB HMenu
  112.  
  113.     ON SelectNum GOSUB DoEdit , DoFile , DoPrint , DoHelp , DoExit
  114.  
  115.     NewWindow = False
  116.  
  117. GOTO MainLoop
  118.  
  119.     '| Edit command selection
  120. DoEdit: 
  121.     W = 2    
  122.     X = 1 
  123.     Y = 1 
  124.  
  125.     '|  Display text
  126.     Text$ = "Edit: Enter text, press <ESC> when finished "
  127.     GOSUB WriteWindow
  128.  
  129.     WHILE KeyCode <> 27 
  130.           GOSUB GetKeyCode 
  131.     WEND
  132.  
  133. RETURN
  134.  
  135.     '| Files command selection
  136. DoFile: 
  137.     VSelectWidth = 10
  138.     VSelect$(1) = "Get"
  139.     VSelect$(2) = "Save"
  140.     VSelect$(3) = "Delete"
  141.     VSelect$(4) = "Return"
  142.     VNumSelects = 4
  143.  
  144.     '|  Display pull-down menu
  145.     GOSUB VMenu
  146.  
  147.     IF SelectNum = 4                        _
  148.        THEN GOSUB KillWindow :                     _
  149.         RETURN
  150.  
  151.     '|  Create a new window to display filename prompt
  152.     X = NowX(NowWindow)
  153.  
  154.     IF X + 2 > ScreenWidth                        _
  155.        THEN X = X - VSelectWidth - 2
  156.  
  157.     Y = NowY(NowWindow) + VNumSelects + 2
  158.     WHeight = 1
  159.     WWidth = 29
  160.     GOSUB AddWindow
  161.  
  162.     ' Now X and Y are relative to the window
  163.     X = 1
  164.     Y = 1
  165.     W = NowWindow
  166.     Text$ = "Enter Filename: "
  167.     Check = LEN(Text$)
  168.     GOSUB WriteWindow
  169.     X = CSRLIN
  170.     Y = POS(0)
  171.     KeyMax = 12
  172.     Text$ = ""
  173.     GOSUB GetKeyInput
  174.  
  175.     ' Show the input 
  176.     TempX = CSRLIN : TempY = POS(0)
  177.     LOCATE X , Y - Check 
  178.      PRINT "   You entered: "; Text$;
  179.      LOCATE TempX , TempY
  180.     SOUND 2222 , 1
  181.      Dly = 2
  182.      GOSUB Delay
  183.  
  184.     ' Remove filename window
  185.      GOSUB KillWindow
  186.  
  187.     ' Remove files window
  188.      GOSUB KillWindow
  189. RETURN
  190.  
  191.     '| Print command selection
  192. DoPrint: 
  193.     ' Set up & display pull-down menu
  194.     VSelectWidth = 12
  195.     VSelect$(1) = "to Printer"
  196.     VSelect$(2) = "to File"
  197.     VSelect$(3) = "Return"
  198.     VNumSelects = 3
  199.      GOSUB VMenu
  200.  
  201.     ' Evaluate selection
  202.     IF SelectNum = 3                        _
  203.        THEN GOSUB KillWindow :                    _
  204.         RETURN
  205.  
  206.     IF SelectNum = 1                        _
  207.        THEN PrintFlag = 1 :                        _
  208.        GOSUB KillWindow :                         _
  209.        RETURN
  210.  
  211.     X = NowX(NowWindow)
  212.     Y = NowY(NowWindow) + VNumSelects + 2
  213.  
  214.     ' Check for X out of bounds
  215.     IF X + 2 > ScreenWidth                        _
  216.        THEN X = X - VSelectWidth - 2
  217.  
  218.     ' Create a window for prompt
  219.     WHeight = 1
  220.     WWidth = 29
  221.     GOSUB AddWindow
  222.  
  223.     '| Make sure window will fit
  224.     IF X + WWidth + 2 > ScreenWidth                    _
  225.        THEN X = ScreenWidth - WWidth - 2
  226.  
  227.     X = 1
  228.     Y = 1
  229.     W = NowWindow
  230.  
  231.     ' Display filename prompt
  232.     Text$="Enter filename: "  
  233.     GOSUB WriteWindow
  234.  
  235.     X = CSRLIN
  236.     Y = POS(0)
  237.     KeyMax = 12
  238.     Text$ = ""
  239.     GOSUB GetKeyInput
  240.  
  241.     ' Show the input
  242.     TempX = CSRLIN : TempY = POS(0)
  243.     LOCATE X , Y - Check 
  244.      PRINT "   You entered: "; Text$;
  245.      LOCATE TempX , TempY
  246.  
  247.     SOUND 2222 , 1
  248.     Dly = 2
  249.     GOSUB Delay
  250.  
  251.     ' Remove the filename window
  252.     GOSUB KillWindow
  253.  
  254.     ' Remove print window
  255.     GOSUB KillWindow
  256. RETURN
  257.  
  258.     '| Help selection
  259. DoHelp: 
  260.     VSelectWidth = 12
  261.     VSelect$(1) = "for Edit"
  262.     VSelect$(2) = "for Files"
  263.     VSelect$(3) = "for Print"
  264.     VSelect$(4) = "Return"
  265.     VNumSelects = 4
  266.  
  267.     ' Display pull-down menu
  268.     GOSUB VMenu
  269.  
  270.     IF SelectNum = 4                        _
  271.        THEN GOSUB KillWindow :                    _
  272.         RETURN
  273.  
  274.     '|  Create a new window to display help
  275.     X = NowX(NowWindow)
  276.  
  277.     IF X + 2 > ScreenWidth                        _
  278.        THEN X = X - VSelectWidth - 2
  279.  
  280.     Y = NowY(NowWindow) + VNumSelects + 2
  281.     WHeight = 9
  282.     WWidth = 22 + LEN(VSelect$(SelectNum))
  283.     GOSUB AddWindow
  284.  
  285.     ' Now X and Y are relative to the window
  286.     X = 2
  287.     Y = 5
  288.     W = NowWindow
  289.     Text$ = "This is dummy Help " + VSelect$(SelectNum) + "."
  290.     GOSUB WriteWindow
  291.  
  292.     SOUND 2222 , 1
  293.     Dly = 3
  294.      GOSUB Delay
  295.  
  296.     ' Remove filename window
  297.      GOSUB KillWindow
  298.  
  299.     ' A real program would have printed help here
  300.  
  301.     ' Remove the menu
  302.     GOSUB KillWindow
  303.     RETURN
  304.  
  305.     '| Exit program
  306. DoExit:
  307.     GOSUB KillWindow
  308.     GOSUB KillWindow
  309.     LOCATE 12,1
  310.     PRINT SPC(36);"Goodbye !             "
  311.  
  312. SYSTEM
  313. ' >>>>> Physical EOF WINDODMO.ASC  25 June 86
  314.